function getTime(time: string | any) {
  //time 2022-12-12 12:00:00
  if (time) {
    time = time.replace(/-/g, "/")
  } else {
    time = Date.now()
  }

  const date = new Date(time)

  return {
    y: date.getFullYear(), //年
    m: (date.getMonth() + 1 + "").padStart(2, "0"), //月
    d: (date.getDate() + "").padStart(2, "0"), //日
    h: (date.getHours() + "").padStart(2, "0"), //时
    mi: (date.getMinutes() + "").padStart(2, "0"), //分
    s: (date.getSeconds() + "").padStart(2, "0"), //秒
  }
}

export { getTime }
